//
//  CJCommissionView.m
//  Boss
//
//  Created by admin on 2018/9/12.
//  Copyright © 2018年 admin. All rights reserved.
//

#import "CJCommissionView.h"
@interface CJCommissionView()

@property (strong, nonatomic) IBOutlet UIProgressView *progressView;
@property (strong, nonatomic) IBOutlet UIImageView *userImageView;
@property (strong, nonatomic) IBOutlet UILabel *userName;

@property (strong, nonatomic) IBOutlet UILabel *clickMoeny;
@property (strong, nonatomic) IBOutlet UIButton *clickCount;
@property (strong, nonatomic) IBOutlet UILabel *allPriceLabel;
@property (strong, nonatomic) IBOutlet UILabel *blanceMoeny;
@property (strong, nonatomic) IBOutlet UIButton *stateBtn;
@property (strong, nonatomic) IBOutlet UILabel *allPersonCount;
@property (strong, nonatomic) IBOutlet UIButton *moreBtn;


@property (strong, nonatomic) IBOutlet UILabel *profitAmountLabel;
@property (strong, nonatomic) IBOutlet UILabel *effectiveClick;

@property (strong, nonatomic) IBOutlet UIView *view1;

@property (strong, nonatomic) IBOutlet UIView *view2;


@end
@implementation CJCommissionView

-(instancetype)initWithCoder:(NSCoder *)aDecoder
{
    if (self = [super initWithCoder:aDecoder]) {
        self.progressView.layer.cornerRadius = 5.f;
    }
    return self;
}
-(void)setHeaderModel:(CJCommissionHeader *)headerModel
{
    _headerModel = headerModel;
    
    WYUserMessage *userMessage = [WYStoreModule currentUserMessage];
    [self.userImageView sd_setImageWithURL:[NSURL URLWithString:userMessage.url]];
    self.userName.text = userMessage.userName;
    self.clickMoeny.text = [NSString stringWithFormat:@"%@ 元",headerModel.clickMoney];
    
    float a  = headerModel.totalMoney.floatValue-headerModel.balanceMoney.floatValue;
    float b = headerModel.totalMoney.floatValue;
    NSLog(@"百分比 ====  %f",a/b);
    self.progressView.progress =a / b;
    
    self.allPriceLabel.text = [NSString stringWithFormat:@"总计¥ %@",headerModel.totalMoney];
    self.blanceMoeny.text = [NSString stringWithFormat:@"剩余 ¥%@",headerModel.balanceMoney];
    
    if (headerModel.state.integerValue==2) {
        [self.stateBtn setTitle:@" 进行中 " forState:(UIControlStateNormal)];
        [self.stateBtn setBorderWithWidth:kLineHeight andColor:[UIColor hexStringToColor:@"#eaeaea" alpha:1.0]];
        [self.stateBtn setTitleColor:[UIColor hexStringToColor:@"#eaeaea" alpha:1.0] forState:(UIControlStateNormal)];
        self.stateBtn.titleLabel.font = [UIFont systemFontOfSize:10];
        
        
        
    }else{
        [self.stateBtn setTitle:@" 进行中 " forState:(UIControlStateNormal)];
        [self.stateBtn setBorderWithWidth:kLineHeight andColor:[UIColor hexStringToColor:@"#d8593f" alpha:1.0]];
        [self.stateBtn setTitleColor:[UIColor hexStringToColor:@"#d8593f" alpha:1.0] forState:(UIControlStateNormal)];
        self.stateBtn.titleLabel.font = [UIFont systemFontOfSize:10];
        
    }
    
    self.profitAmountLabel.text = [NSString stringWithFormat:@"%.2f",headerModel.profitAmount.floatValue];
    self.effectiveClick.text = headerModel.effectiveClick;
    
    
    if (headerModel.share.integerValue) {
        self.view1.hidden = NO;
        self.view2.hidden = NO;
    }else{
        self.view1.hidden = YES;
        self.view2.hidden = YES;
    }
    
    
    
    
}


-(void)setCountString:(NSString *)countString
{
    _countString = countString;
    self.allPersonCount.text = [NSString stringWithFormat:@"%@人",countString];
    if (countString.integerValue<=10) {
        self.moreBtn.hidden = YES;
    }else{
        self.moreBtn.hidden = NO;
    }
    
    
}




-(void)awakeFromNib
{
    [super awakeFromNib];
    self.progressView.layer.cornerRadius = 5.f;
    [self.userImageView setCornerRadius:33.f];
}

- (IBAction)moreAction:(id)sender {
    if ([self.delegate respondsToSelector:@selector(clickMoreBoss)]) {
        [self.delegate clickMoreBoss];
    }
}




@end
